home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Draw / Sources / DrawFrame.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  4.6 KB  |  189 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawFrame.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //    Creation Date:        3/28/94
  8. //
  9. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef DRAWFRAME_H
  14. #include "DrawFrame.h"
  15. #endif
  16.  
  17. #ifndef DRAWPART_H
  18. #include "DrawPart.h"
  19. #endif
  20.  
  21. #ifndef DRAWSELECTION_H
  22. #include "DrawSelection.h"
  23. #endif
  24.  
  25. #ifndef UTILITIES_H
  26. #include "Utilities.h"
  27. #endif
  28.  
  29. #ifndef SHAPES_H
  30. #include "Shapes.h"
  31. #endif
  32.  
  33. #ifndef DRAWDACET_H
  34. #include "DrawFacet.h"
  35. #endif
  36.  
  37. // ----- Framework Includes -----
  38.  
  39. #ifndef FWUTIL_H
  40. #include "FWUtil.h"
  41. #endif
  42.  
  43. #ifndef FWFACET_H
  44. #include "FWFacet.h"
  45. #endif
  46.  
  47. // ----- OpenDoc Includes -----
  48.  
  49. #ifndef _MENUBAR_
  50. #include "MenuBar.h"
  51. #endif
  52.  
  53. #ifndef _WINDOW_
  54. #include "Window.h"
  55. #endif
  56.  
  57. #ifndef _SHAPE_
  58. #include "Shape.h"
  59. #endif
  60.  
  61. #ifndef _DRAFT_
  62. #include "Draft.h"
  63. #endif
  64.  
  65. #ifndef _TRNSFORM_
  66. #include "Trnsform.h"
  67. #endif
  68.  
  69. #pragma segment drawpart
  70.  
  71. //=========================================================================
  72. // CDrawFrame
  73. //=========================================================================
  74.  
  75. //------------------------------------------------------------------------------
  76. // CDrawFrame::CDrawFrame
  77. //------------------------------------------------------------------------------
  78.  
  79. CDrawFrame::CDrawFrame()
  80. {
  81. }
  82.  
  83. //------------------------------------------------------------------------------
  84. // CDrawFrame::IDrawFrame
  85. //------------------------------------------------------------------------------
  86.  
  87. void CDrawFrame::IDrawFrame(XMPFrame* xmpFrame, CDrawPart* drawPart)
  88. {
  89.     InitEmbeddingFrame(xmpFrame, drawPart);
  90.     
  91.     // ----- By default we put all of them
  92.     AddToFocusSet(drawPart->GetKeyFocusToken());
  93.     AddToFocusSet(drawPart->GetMenuFocusToken());
  94.     AddToFocusSet(drawPart->GetSelectionFocusToken());
  95.     
  96.     fDrawPart = drawPart;
  97.  
  98.     this->SetDroppable(TRUE);
  99. }
  100.  
  101. //------------------------------------------------------------------------------
  102. // CDrawFrame::~CDrawFrame
  103. //------------------------------------------------------------------------------
  104.  
  105. CDrawFrame::~CDrawFrame()
  106. {
  107. }
  108.  
  109. //------------------------------------------------------------------------------
  110. // CDrawFrame::RemoveEmbeddedFrame
  111. //------------------------------------------------------------------------------
  112.  
  113. void CDrawFrame::RemoveEmbeddedFrame(FW_CProxyFrame* proxy)
  114. {
  115.     // ----- Invalidate the shape of the old frame -----
  116.     XMPShape* shape = ::NewXMPShape();
  117.     proxy->GetFrameShape(shape);
  118.     proxy->Invalidate(shape);
  119.     delete shape;
  120.     
  121.     // ----- Call inherited -----
  122.     FW_CEmbeddingFrame::RemoveEmbeddedFrame(proxy);
  123.     
  124.     // ------ Clip -----
  125.     ClipEmbeddedFrames();
  126. }
  127.  
  128. //-------------------------------------------------------------------------
  129. // CDrawFrame::HandleKeyDown
  130. //-------------------------------------------------------------------------
  131.  
  132. FW_Boolean CDrawFrame::HandleKeyDown(XMPEventData event)
  133. {
  134. FW_UNUSED(event);
  135.     return TRUE;
  136. }
  137.  
  138. //------------------------------------------------------------------------------
  139. // CDrawFrame::ActiveStateChanged
  140. //------------------------------------------------------------------------------
  141.  
  142. void CDrawFrame::FocusStateChanged(XMPTypeToken focus, FW_Boolean newState)
  143. {    
  144.     FW_CEmbeddingFrame::FocusStateChanged(focus, newState);
  145.  
  146.     if (focus == GetPart()->GetSelectionFocusToken())
  147.     {
  148.         CDrawSelection *selection = (CDrawSelection*)fDrawPart->GetSelection();
  149.         
  150.         selection->DrawAllHandles(this, newState);
  151.     }
  152. }
  153.  
  154. //------------------------------------------------------------------------------
  155. // CDrawFrame::NewFacet
  156. //------------------------------------------------------------------------------
  157.  
  158. FW_CFacet* CDrawFrame::NewFacet(XMPFacet* xmpFacet)
  159. {
  160.     CDrawFacet* facet = new CDrawFacet;
  161.     facet->IDrawFacet(xmpFacet, fDrawPart);
  162.     return facet;
  163. }
  164.  
  165. //------------------------------------------------------------------------------
  166. //     CDrawFrame::UsedShapeChanged
  167. //
  168. //------------------------------------------------------------------------------
  169.  
  170. void CDrawFrame::UsedShapeChanged(FW_CProxyRun* proxyRun, XMPFrame* embeddedXMPFrame)
  171. {
  172.     XMPShape *oldUpdateShape = ::NewXMPShape();
  173.     CProxyShape* shape = ((CDrawProxyRun*)proxyRun)->GetShape();
  174.     shape->GetUpdateShape(oldUpdateShape);
  175.     oldUpdateShape->Transform(GetInternalTransform());
  176.     
  177.     FW_CEmbeddingFrame::UsedShapeChanged(proxyRun, embeddedXMPFrame);
  178.     
  179.     XMPShape *updateShape = ::NewXMPShape();
  180.     shape->GetUpdateShape(updateShape);
  181.     updateShape->Transform(GetInternalTransform());
  182.  
  183.     updateShape->Union(oldUpdateShape);
  184.     delete oldUpdateShape;
  185.     
  186.     InvalidateAllFacets(NULL, updateShape);
  187.     delete updateShape;
  188. }
  189.